<template>
  <el-dialog
    title="“妥钱包”企业资质认证"
    width="700px"
    center
    :show-close="false"
    :close-on-click-modal="false"
    :close-on-press-escape="false"
    :visible="visible"
    @update:visible="$emit('update:visible', $event)"
    v-loading="loading"
  >
    <div style="font-size: 16px;text-indent: 2em; line-height: 1.6;">
      如果您同意
      <a style="color: #409eff" :href="`//${buyerDomain}/certification/paymentAgr`" target="_blank"> 《“妥了网”平台交易支付服务协议》</a>
      协议的全部条款，请点击“同意”，一经同意，该协议即在乐活科技（妥了网）和您之间产生法律效力，双方需严格履行该协议。
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="onOpen">同 意</el-button>
    </span>
  </el-dialog>
</template>

<script>
import { getDomain } from '@/api/common';

export default {
  name: 'OpenWallet',

  props: {
    visible: Boolean,
  },

  data () {
    return {
      loading: true,
      buyerDomain: '',
    };
  },

  created () {
    this.getData();
  },

  methods: {
    async getData () {
      const p = [];
      p.push(getDomain(2)
        .then(domain => {
          this.buyerDomain = domain;
        }));

      await Promise.all(p);
      this.loading = false;
    },

    onOpen () {
      window.open(`//${this.buyerDomain}/lianjinAccount/toseller`);
      this.$emit('update:visible', false);
      this.$emit('confirm', true);
    },
  },
};
</script>
